<template>
	<!--招采管理-物资招采-->
	<a-card :bordered="false" :confirmLoading="confirmLoading">
		<!-- 查询区域 -->
		<div class="table-page-search-wrapper">
			<a-form layout="inline" @keyup.enter.native="searchQuery">
				<a-row :gutter="24">
					<a-col :md="4" :sm="6">
						<a-form-item label="名称">
							<!--<a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>-->
							<j-input placeholder="输入招标名称(模糊查询)" v-model="queryParam.name"></j-input>
						</a-form-item>
					</a-col>


					<a-col :xl="8" :md="8" :sm="12">
						<a-form-item label="发标时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
							<j-date v-model="queryParam.queryStartTime" :showTime="true" date-format="YYYY-MM-DD "
								style="width: 25%" placeholder="请选择开始时间"></j-date>
							<span style="width: 10px">~</span>
							<j-date v-model="queryParam.queryEndTime" :showTime="true" date-format="YYYY-MM-DD"
								style="width: 25%" placeholder="请选择结束时间"></j-date>
						</a-form-item>
					</a-col>

					<a-col :md="4" :sm="8">
						<a-form-item label="项目">
							<a-input placeholder="请输入项目名称" v-model="queryParam.productName"></a-input>
						</a-form-item>
					</a-col>

					<a-col :md="4" :sm="8">
						<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
						<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
					</a-col>

				</a-row>
				<a-row>
					<a-col :md="6" :sm="8">
						<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
							<a-button style="background-color:#32cd99;color: white;" @click="SubmitRecruit"
								icon="plus">创建物资招标信息</a-button>
						</span>
					</a-col>
				</a-row>
			</a-form>
		</div>
		<!-- 查询区域-END -->

		<!-- 操作按钮区域 -->
		<div class="table-operator">
			<!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
			<!-- <a-button type="primary" icon="download" @click="handleExportXls('wt_public_bidding')">导出</a-button> -->
			<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
          <a-button type="primary" icon="import">导入</a-button>
        </a-upload> -->
			<!-- 高级查询区域 -->
			<!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
        <a-dropdown v-if="selectedRowKeys.length > 0">
          <a-menu slot="overlay">
            <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
          </a-menu>
          <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
        </a-dropdown> -->
		</div>

		<!-- table区域-begin -->
		<div>
			<!--        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
			<!--          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
			<!--          <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
			<!--        </div>-->

			<a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
				:dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
				@change="handleTableChange">
				<template slot="htmlSlot" slot-scope="text">
					<div v-html="text"></div>
				</template>

				<span slot="action" slot-scope="text, record">
					<div>
						<a @click="handleFabiao(record)" v-if="record.status == '0'">
							发标
						</a>
						<a-divider type="vertical"  v-if="record.status == '0'"/>
						
						<a @click="handleResult(record,'supplier')" v-if="record.status == '1'">
							应标结果
						</a>
						<a-divider type="vertical" v-if="record.status == '1'"/>
						
						<a v-if="record.status == '0'" @click="handleXiugai(record)">修改</a>
						<a-divider type="vertical" v-if="record.status == '0'"/>
						
						<a v-if="record.status == '1'" @click="handleXiang(record)">详情</a>
						<a-divider type="vertical" v-if="record.status == '1'"/>
						
						<a v-if="record.status == '3'" @click="viewMaterialResultModal(record)">查看会签表</a>
						<a-divider v-if="record.status == '3'" type="vertical" />

						<a v-if="record.status == '3'" @click="uploa(record)">上传会签表</a>
						<a-divider v-if="record.status == '3'" type="vertical" />
						
						<a @click="handleEnd(record)" v-if="record.status == '4'">详情</a>
						<a-divider type="vertical" v-if="record.status == '4'"/>
						<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
							<a>删除</a>
						</a-popconfirm>
					</div>
					<!--<div>
            <a @click="handleFabiao(record)">发标</a>

            <a-divider type="vertical" />
            <a @click="handleXiugai(record)">修改</a>
          </div>-->

					<!-- <div>
            <a disabled>已发标</a>

            <a-divider type="vertical" />
            <a @click="handleXiang(record)">详情</a>
          </div>-->

					<!-- <a-dropdown>
              <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
              <a-menu slot="overlay">
                <a-menu-item>
                  <a @click="handleDetail(record)">修改</a>
                </a-menu-item>
                <a-menu-item>
                  <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a>删除</a>
                  </a-popconfirm>
                </a-menu-item>
              </a-menu>
            </a-dropdown> -->
				</span>
			</a-table>
		</div>

		<wt-public-bidding-modal ref="modalForm" @ok="modalFormOk"></wt-public-bidding-modal>
		<wt-public-bidding-recruit-modal ref="modalForm1" @ok="modalFormOk"></wt-public-bidding-recruit-modal>
		<wt-public-modal ref="modalForm2" @ok="modalFormOk"></wt-public-modal>
		<wt-xiang-modal ref="modalForm3" @ok="modalFormOk"></wt-xiang-modal>
		<wt-public-result-modal ref="modalForm4" @ok="modalFormOk" @ok4="modalFormOk"></wt-public-result-modal>
		<Wtuploadfile :issueTime="issueTime" :traneIncTime="traneIncTime" :id="id" @handleOk="modalFormOk"
			ref="uploadfile"></Wtuploadfile>
		<huiqian2 ref="huiqian2" @tolink="tolink" />
		<zhaopiaoend :id="id" ref="zhaopiaoend"></zhaopiaoend>
	</a-card>
</template>

<script>
	import {
		httpAction,
		getAction
	} from '@/api/manage'
	import '@/assets/less/TableExpand.less'
	import {
		mixinDevice
	} from '@/utils/mixin'
	import {
		JeecgListMixin
	} from '@/mixins/JeecgListMixin'
	import WtPublicBiddingModal from './modules/WtPublicBiddingModal'
	import WtPublicBiddingRecruitModal from './modules/WtPublicBiddingRecruitModal.vue'
	import WtPublicModal from './modules/WtPublicBiddingxiuModal.vue'
	import WtXiangModal from './modules/WtPublicBiddingRecruitxiangModal.vue'
	import HuiqianModal from './modules/huiqian.vue'
	import Wtuploadfile from './modules/uploadfile.vue'
	import WtPublicResultModal from './modules/WtPublicBiddingRecruitResultModal'
	import huiqian2 from './modules/huiqian2'
	import zhaopiaoend from './modules/zhaopiaoEnd'
	import JDate from '@/components/jeecg/JDate'
	export default {
		name: 'WtPublicBiddingList',
		mixins: [JeecgListMixin, mixinDevice],
		inject: ['closeCurrent'],
		components: {
			WtPublicBiddingModal,
			JDate,
			WtPublicBiddingRecruitModal,
			WtPublicModal,
			WtXiangModal,
			WtPublicResultModal,
			HuiqianModal,
			Wtuploadfile,
			huiqian2: huiqian2,
			zhaopiaoend
		},
		data() {
			return {
				id: '',
				publicBiddingId: '',
				isDisabled: false,
				isShow: false,
				description: 'wt_public_bidding管理页面',
				// 表头
				labelCol: {
					xs: {
						span: 24
					},
					sm: {
						span: 5
					},
				},
				wrapperCol: {
					xs: {
						span: 24
					},
					sm: {
						span: 16
					},
				},
				queryParam: {
					queryEndTime: '',
					queryStartTime: '',
					type: '0'
				},

				columns: [
					// {
					//   title: '序号',
					//   dataIndex: '',
					//   key: 'rowIndex',
					//   width: 60,
					//   align: 'center',
					//   customRender: function (t, r, index) {
					//     return parseInt(index) + 1
					//   },
					// },
					{
						title: '招标名称',
						align: 'center',
						dataIndex: 'name',
					},
					{
						title: '发标时间',
						align: 'center',
						dataIndex: 'issueTime',
						customRender: function(text) {
							return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
						},
					},
					{
						title: '结标时间',
						align: 'center',
						dataIndex: 'traneIncTime',
						customRender: function(text) {
							return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
						},
					},
					{
						title: '项目',
						align: 'center',
						dataIndex: 'project',
					},
					{
						title: '状态',
						align: 'center',
						dataIndex: 'status_dictText',
					},
					{
						title: '中标候选人',
						align: 'center',
						dataIndex: 'supplierId',
					},

					// {
					//   title:'备注',
					//   align:"center",
					//   dataIndex: 'remark'
					// },

					{
						title: '操作',
						dataIndex: 'action',
						align: 'center',
						fixed: 'right',
						width: 147,
						scopedSlots: {
							customRender: 'action'
						},
					},
				],
				url: {
					list: '/bidding/wtPublicBidding/list',
					delete: '/bidding/wtMaterialsSupplierPrice/delete',
					deleteBatch: '/bidding/wtMaterialsSupplierPrice/deleteBatch',
					exportXlsUrl: '/bidding/wtMaterialsSupplierPrice/exportXls',
					importExcelUrl: 'bidding/wtMaterialsSupplierPrice/importExcel',
				},
				dictOptions: {},
				superFieldList: [],
			}
		},
		created() {
			this.getSuperFieldList()
		},
		computed: {
			importExcelUrl: function() {
				return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
			},
		},
		methods: {
			tolink(type, objlist) {
				let _self = this;
				_self.closeCurrent();
				setTimeout(() => {
					_self.$router.push({
						path: '/modules/HuiQianGuanLi/DanJuShenQi',
						query: {
							id: 1,
							billsTemplateName: type,
							objlist: objlist
						}
					});
				}, 300)
			},
			handleEnd(record) {

				this.$refs.zhaopiaoend.edit(record);
				this.$refs.zhaopiaoend.disableSubmit = true
				this.countersignUrl = record.countersignUrl

			},
			viewMaterialResultModal(record) {
				this.$refs.huiqian2.showInfo(record);
				this.$refs.huiqian2.disableSubmit = false
			},
			uploa(record) {
				this.$refs.uploadfile.edit(record)
				var _this = this
				_this.id = record.id
				_this.issueTime = record.issueTime
				_this.traneIncTime = record.traneIncTime
				this.$refs.modalForm1.title = "上传会签表";

			},
			handleResult: function(record,type) {
				this.$refs.modalForm4.edit(record,type);
				this.$refs.modalForm4.title = "应标结果";
				this.$refs.modalForm4.disableSubmit = false;
			},
			initDictConfig() {},
			getSuperFieldList() {
				let fieldList = []
				fieldList.push({
					type: 'string',
					value: 'name',
					text: '名称'
				})
				fieldList.push({
					type: 'date',
					value: 'issueTime',
					text: '发布时间'
				})
				fieldList.push({
					type: 'date',
					value: 'traneIncTime',
					text: '结标时间'
				})
				fieldList.push({
					type: 'string',
					value: 'project',
					text: '项目'
				})
				fieldList.push({
					type: 'string',
					value: 'status',
					text: '状态'
				})
				fieldList.push({
					type: 'string',
					value: 'supplierId',
					text: '中标候选人'
				})
				fieldList.push({
					type: 'string',
					value: 'technicalRequirements',
					text: '技术要求'
				})
				this.superFieldList = fieldList
			},
		},
	}
</script>
<style scoped>
	@import '~@assets/less/common.less';
</style>